﻿using System;
using UnityEngine;
using Yoozoo.Core.Common;
using Yoozoo.Mars.Got;

namespace Yoozoo.Core.Timeline
{
    public class TLineObjectAvatar : MonoBehaviour
    {
        public GameObject prefab;
        public GameObject instance;

        [Header("性能分级，大于等于此品质才会显示")]
        public QualityEnum qualityLimit = QualityEnum.None;
        
        public void OnEnable()
        {
            //Build();
        }

        public void Build()
        {
            if (QualityManager.Inst == null || QualityManager.Inst.QualityValue > (int)qualityLimit)
            {
                if (prefab != null && instance == null)
                {
                    instance = GameObject.Instantiate(prefab, transform);
                    instance.transform.localPosition = Vector3.zero;
                    instance.transform.localRotation = Quaternion.identity;
                    instance.transform.localScale = Vector3.one;
                }
            }
        }

        public void Hide()
        {
            if (instance!=null)
            {
                GameObject.DestroyImmediate(instance);
                instance = null;
            }
        }
        
    }
}